{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8d938199",
   "metadata": {},
   "source": [
    "### 用户输入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f32256a2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "username:momge\n",
      "password:1234567890\n",
      "momge 1234567890\n"
     ]
    }
   ],
   "source": [
    "# -*- coding:utf-8 -*-\n",
    "# Author:momge\n",
    "\n",
    "username = input(\"username:\")\n",
    "password = input(\"password:\")\n",
    "\n",
    "print(username,password)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "36e9c9ff",
   "metadata": {},
   "source": [
    "### 字符串拼接+打印"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ffe767d0",
   "metadata": {},
   "source": [
    "#### 麻烦版"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a50105c3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name:momge\n",
      "age:23\n",
      "job:student\n",
      "salary:300000\n",
      "----- INFO OF momge------\n",
      "age:23\n",
      "job:student\n",
      "salary:300000\n"
     ]
    }
   ],
   "source": [
    "name = input(\"name:\")\n",
    "age = input(\"age:\")\n",
    "job = input(\"job:\")\n",
    "salary = input(\"salary:\")\n",
    "\n",
    "info = '''----- INFO OF ''' + name +'''------''' + '''\n",
    "age:''' + age+'''\n",
    "job:''' + job +'''\n",
    "salary:'''+salary\n",
    "\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5cdd7261",
   "metadata": {},
   "source": [
    "#### 简化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "12cfeff8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name:momge\n",
      "age:20\n",
      "job:student\n",
      "salary:50000\n",
      "-------INFO OF momge -------\n",
      "Name:momge\n",
      "Age:20\n",
      "Job:student\n",
      "Salary:50000\n",
      "\n"
     ]
    }
   ],
   "source": [
    "name = input(\"name:\")\n",
    "age = input(\"age:\")\n",
    "job = input(\"job:\")\n",
    "salary = input(\"salary:\")\n",
    "\n",
    "info = '''-------INFO OF %s -------\n",
    "Name:%s\n",
    "Age:%s\n",
    "Job:%s\n",
    "Salary:%s\n",
    "'''% (name,name,age,job,salary)\n",
    "\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e47f5173",
   "metadata": {},
   "source": [
    "* \n",
    "%s代表 string\n",
    "\n",
    "%d代表 number\n",
    "\n",
    "%f代表 float"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ecbd0260",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name:momge\n",
      "age:20\n",
      "job:student\n",
      "salary:40000000\n",
      "-------INFO OF momge -------\n",
      "Name:momge\n",
      "Age:20\n",
      "Job:student\n",
      "Salary:40000000\n",
      "\n"
     ]
    }
   ],
   "source": [
    "name = input(\"name:\")\n",
    "age = int(input(\"age:\"))  #python中默认所有的输入均为string\n",
    "job = input(\"job:\")\n",
    "salary = int(input(\"salary:\"))\n",
    "\n",
    "info = '''-------INFO OF %s -------\n",
    "Name:%s\n",
    "Age:%d\n",
    "Job:%s\n",
    "Salary:%d\n",
    "'''% (name,name,age,job,salary)\n",
    "\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7c95e79b",
   "metadata": {},
   "source": [
    "#### .format(): ；两种都可以"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "5dac2967",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-------INFO OF momge -------\n",
      "Name:momge\n",
      "Age:20\n",
      "Job:student\n",
      "Salary:40000000\n",
      "\n"
     ]
    }
   ],
   "source": [
    "info2 =  '''-------INFO OF {_name} -------\n",
    "Name:{_name}\n",
    "Age:{_age}\n",
    "Job:{_job}\n",
    "Salary:{_salary}\n",
    "'''.format(_name=name,\n",
    "           _age=age,\n",
    "           _job=job,\n",
    "           _salary=salary)\n",
    "print(info2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "5ce23706",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-------INFO OF momge -------\n",
      "Name:momge\n",
      "Age:20\n",
      "Job:student\n",
      "Salary:40000000\n",
      "\n"
     ]
    }
   ],
   "source": [
    "info3 =  '''-------INFO OF {0} -------\n",
    "Name:{0}\n",
    "Age:{1}\n",
    "Job:{2}\n",
    "Salary:{3}\n",
    "'''.format(name,age,job,salary)\n",
    "print(info3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "51a3b82e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "weekday:sunday\n",
      "别睡啦！准备上课！\n"
     ]
    }
   ],
   "source": [
    "# Author:momge\n",
    "\n",
    "today = input(\"weekday:\")\n",
    "if today == \"Saturday\":\n",
    "    print(\"休息\")\n",
    "elif today == \"Sunday\":\n",
    "    condition = input(\"mood:\")\n",
    "    if condition == \"Headache\":\n",
    "        print(\"Recover, then rest.\")\n",
    "    else:\n",
    "        print(\"Rest.\")\n",
    "else:\n",
    "    print(\"别睡啦！准备上课！\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1c47028d",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "hide_input": false,
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
